# encoding: UTF-8
#
require 'iconv'
require "FileUtils"
def get_all_file_full_path(home,result=nil)  
	result ||= []
	Dir.entries(home).each do |sub|       
		next if sub=="." or sub ==".."
		#sub = Iconv.conv("UTF-8","GBK", sub )
		puts sub
		if File.directory?("#{home}/#{sub}")
			get_all_file_full_path("#{home}/#{sub}", result)  
		else  
			result<<"#{home}/#{sub}"  
		end    
	end
   result
end

home = ARGV[0]
result = get_all_file_full_path(home)

result.each do |name|
	#name = Iconv.conv("GBK","UTF-8", name )
	if File.exist? name
		puts "file: #{name} already exist"
		next
	end
	# move
	#FileUtils.mv name,home
	# copy 
	FileUtils.cp name,home
end
